/**
 * <copyright>
 *
 * Copyright (c) 2011 Zeligsoft (2009) Limited
 * All rights reserved.   This program and the accompanying materials
 * are made available under the terms of the Eclipse Public License v1.0
 * which accompanies this distribution, and is available at
 * http://www.eclipse.org/legal/epl-v10.html
 * 
 * Contributors: 
 *   Zeligsoft (2009) Limited - Initial API and implementation
 *
 * </copyright>
 *
 */
package org.omg.deployment.parts.forms;

import java.util.ArrayList;
import java.util.List;

import org.eclipse.emf.ecore.EObject;
import org.eclipse.emf.ecore.EReference;
import org.eclipse.emf.edit.ui.provider.AdapterFactoryLabelProvider;
import org.eclipse.emf.eef.runtime.api.component.IPropertiesEditionComponent;
import org.eclipse.emf.eef.runtime.api.notify.IPropertiesEditionEvent;
import org.eclipse.emf.eef.runtime.api.parts.IFormPropertiesEditionPart;
import org.eclipse.emf.eef.runtime.impl.notify.PropertiesEditionEvent;
import org.eclipse.emf.eef.runtime.impl.parts.CompositePropertiesEditionPart;
import org.eclipse.emf.eef.runtime.ui.parts.PartComposer;
import org.eclipse.emf.eef.runtime.ui.parts.sequence.BindingCompositionSequence;
import org.eclipse.emf.eef.runtime.ui.parts.sequence.CompositionSequence;
import org.eclipse.emf.eef.runtime.ui.utils.EditingUtils;
import org.eclipse.emf.eef.runtime.ui.widgets.referencestable.ReferencesTableContentProvider;
import org.eclipse.emf.eef.runtime.ui.widgets.referencestable.ReferencesTableSettings;
import org.eclipse.jface.viewers.ArrayContentProvider;
import org.eclipse.jface.viewers.ILabelProviderListener;
import org.eclipse.jface.viewers.IStructuredSelection;
import org.eclipse.jface.viewers.ITableLabelProvider;
import org.eclipse.jface.viewers.TableViewer;
import org.eclipse.jface.viewers.ViewerFilter;
import org.eclipse.swt.SWT;
import org.eclipse.swt.events.SelectionAdapter;
import org.eclipse.swt.events.SelectionEvent;
import org.eclipse.swt.graphics.Image;
import org.eclipse.swt.layout.GridData;
import org.eclipse.swt.layout.GridLayout;
import org.eclipse.swt.widgets.Button;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Event;
import org.eclipse.swt.widgets.Listener;
import org.eclipse.swt.widgets.TableColumn;
import org.eclipse.ui.forms.widgets.Form;
import org.eclipse.ui.forms.widgets.FormToolkit;
import org.eclipse.ui.forms.widgets.ScrolledForm;
import org.eclipse.ui.forms.widgets.Section;
import org.omg.deployment.InstanceResourceDeploymentDescription;
import org.omg.deployment.parts.DeployedResourcePropertiesEditionPart;
import org.omg.deployment.parts.DeploymentViewsRepository;
import org.omg.deployment.providers.DeploymentMessages;


/**
 * @author Toby McClean; Zeligsoft (2009) Limited
 * @generated
 */
public class DeployedResourcePropertiesEditionPartForm extends CompositePropertiesEditionPart implements IFormPropertiesEditionPart, DeployedResourcePropertiesEditionPart {

	/**
	 * @generated
	 */
	protected TableViewer resources;
	
	/**
	 * @generated
	 */
	protected List<ViewerFilter> resourcesBusinessFilters = new ArrayList<ViewerFilter>();
	
	/**
	 * @generated
	 */
	protected List<ViewerFilter> resourcesFilters = new ArrayList<ViewerFilter>();
	
	/**
	 * @generated
	 */
	protected TableViewer sharedResources;
	
	/**
	 * @generated
	 */
	protected List<ViewerFilter> sharedResourcesBusinessFilters = new ArrayList<ViewerFilter>();
	
	/**
	 * @generated
	 */
	protected List<ViewerFilter> sharedResourcesFilters = new ArrayList<ViewerFilter>();



	/**
	 * Default constructor
	 * @param editionComponent the {@link IPropertiesEditionComponent} that manage this part
	 * @generated
	 */
	public DeployedResourcePropertiesEditionPartForm(IPropertiesEditionComponent editionComponent) {
    super(editionComponent);
  }

	/**
	 * {@inheritDoc}
	 * 
	 * @see org.eclipse.emf.eef.runtime.api.parts.IFormPropertiesEditionPart#
	 *  createFigure(org.eclipse.swt.widgets.Composite, org.eclipse.ui.forms.widgets.FormToolkit)
	 * @generated
	 */
	public Composite createFigure(final Composite parent, final FormToolkit widgetFactory) {
    ScrolledForm scrolledForm = widgetFactory.createScrolledForm(parent);
    Form form = scrolledForm.getForm();
    view = form.getBody();
    GridLayout layout = new GridLayout();
    layout.numColumns = 3;
    view.setLayout(layout);
    createControls(widgetFactory, view);
    return scrolledForm;
  }

	/**
	 * {@inheritDoc}
	 * 
	 * @see org.eclipse.emf.eef.runtime.api.parts.IFormPropertiesEditionPart#
	 *  createControls(org.eclipse.ui.forms.widgets.FormToolkit, org.eclipse.swt.widgets.Composite)
	 * @generated
	 */
	public void createControls(final FormToolkit widgetFactory, Composite view) {
    CompositionSequence deployedResourceStep = new BindingCompositionSequence(propertiesEditionComponent);
    deployedResourceStep
      .addStep(DeploymentViewsRepository.DeployedResource.DeployedResources.class)
      .addStep(DeploymentViewsRepository.DeployedResource.DeployedResources.resources);
    
    deployedResourceStep
      .addStep(DeploymentViewsRepository.DeployedResource.DeployedSharedResources.class)
      .addStep(DeploymentViewsRepository.DeployedResource.DeployedSharedResources.sharedResources);
    
    
    composer = new PartComposer(deployedResourceStep) {

      @Override
      public Composite addToPart(Composite parent, Object key) {
        if (key == DeploymentViewsRepository.DeployedResource.DeployedResources.class) {
          return createDeployedResourcesGroup(widgetFactory, parent);
        }
        if (key == DeploymentViewsRepository.DeployedResource.DeployedResources.resources) {
          return createResourcesTableComposition(widgetFactory, parent);
        }
        if (key == DeploymentViewsRepository.DeployedResource.DeployedSharedResources.class) {
          return createDeployedSharedResourcesGroup(widgetFactory, parent);
        }
        if (key == DeploymentViewsRepository.DeployedResource.DeployedSharedResources.sharedResources) {
          return createSharedResourcesTableComposition(widgetFactory, parent);
        }
        return parent;
      }
    };
    composer.compose(view);
  }
	/**
   * @generated
   */
  protected Composite createDeployedResourcesGroup(FormToolkit widgetFactory, final Composite parent) {
    Section deployedResourcesSection = widgetFactory.createSection(parent, Section.TITLE_BAR | Section.TWISTIE | Section.EXPANDED);
    deployedResourcesSection.setText(DeploymentMessages.DeployedResourcePropertiesEditionPart_DeployedResourcesGroupLabel);
    GridData deployedResourcesSectionData = new GridData(GridData.FILL_HORIZONTAL);
    deployedResourcesSectionData.horizontalSpan = 3;
    deployedResourcesSection.setLayoutData(deployedResourcesSectionData);
    Composite deployedResourcesGroup = widgetFactory.createComposite(deployedResourcesSection);
    GridLayout deployedResourcesGroupLayout = new GridLayout();
    deployedResourcesGroupLayout.numColumns = 3;
    deployedResourcesGroup.setLayout(deployedResourcesGroupLayout);
    deployedResourcesSection.setClient(deployedResourcesGroup);
    return deployedResourcesGroup;
  }

  /**
	 * @param container
	 * @generated NOT
	 */
	protected Composite createResourcesTableComposition(FormToolkit widgetFactory, Composite container) {
    Composite tableContainer = widgetFactory.createComposite(container, SWT.NONE);
    GridLayout tableContainerLayout = new GridLayout();
    GridData tableContainerData = new GridData(GridData.FILL_BOTH);
    tableContainerData.horizontalSpan = 3;
    tableContainer.setLayoutData(tableContainerData);
    tableContainerLayout.numColumns = 2;
    tableContainer.setLayout(tableContainerLayout);
    org.eclipse.swt.widgets.Table tableResources = widgetFactory.createTable(tableContainer, SWT.FULL_SELECTION | SWT.BORDER);
    tableResources.setHeaderVisible(true);
    tableResources.setEnabled(false);
    tableResources.setToolTipText(DeploymentMessages.DeployedResource_ReadOnly);
    GridData gdResources = new GridData();
    gdResources.grabExcessHorizontalSpace = true;
    gdResources.horizontalAlignment = GridData.FILL;
    gdResources.grabExcessVerticalSpace = true;
    gdResources.verticalAlignment = GridData.FILL;
    tableResources.setLayoutData(gdResources);
    tableResources.setLinesVisible(true);

	    TableColumn resourceName = new TableColumn(tableResources, SWT.NONE);
	    resourceName.setWidth(80);
	    resourceName.setText("Resource Name"); //$NON-NLS-1$
    
	    TableColumn requirementName = new TableColumn(tableResources, SWT.NONE);
	    requirementName.setWidth(80);
	    requirementName.setText("Requirement Name"); //$NON-NLS-1$
    
        TableColumn resourceUsage = new TableColumn(tableResources, SWT.NONE);
        resourceUsage.setWidth(80);
        resourceUsage.setText("Resource Usage"); //$NON-NLS-1$
        
        TableColumn properties = new TableColumn(tableResources, SWT.NONE);
        properties.setWidth(80);
        properties.setText("Properties"); //$NON-NLS-1$
    

    resources = new TableViewer(tableResources);
    resources.setContentProvider(new ArrayContentProvider());
    resources.setLabelProvider(new ITableLabelProvider() {
            public String getColumnText(Object object, int columnIndex) {
             if (object instanceof InstanceResourceDeploymentDescription) {
            	  InstanceResourceDeploymentDescription irdd = (InstanceResourceDeploymentDescription) object;
                switch (columnIndex) {
                case 0:
                  return irdd.getResourceName();
                case 1:
                	return irdd.getRequirementName();
                case 2:
                	return irdd.getResourceUsage().toString();
                }
              }
              return ""; //$NON-NLS-1$
            }
      
            public Image getColumnImage(Object element, int columnIndex) {
              return null;
            }
      

      public void addListener(ILabelProviderListener listener) {
      }

      public void dispose() {
      }

      public boolean isLabelProperty(Object element, String property) {
        return false;
      }

      public void removeListener(ILabelProviderListener listener) {
      }

    });
    resources.getTable().addListener(SWT.MouseDoubleClick, new Listener(){

      public void handleEvent(Event event) {
        if (resources.getSelection() instanceof IStructuredSelection) {
          IStructuredSelection selection = (IStructuredSelection) resources.getSelection();
          if (selection.getFirstElement() instanceof EObject) {
            propertiesEditionComponent.firePropertiesChanged(new PropertiesEditionEvent(DeployedResourcePropertiesEditionPartForm.this, DeploymentViewsRepository.DeployedResource.DeployedResources.resources, PropertiesEditionEvent.COMMIT, PropertiesEditionEvent.EDIT, null, selection.getFirstElement()));
            resources.refresh();
          }
        }
      }

    });
    GridData resourcesData = new GridData(GridData.FILL_HORIZONTAL);
    resourcesData.minimumHeight = 120;
    resourcesData.heightHint = 120;
    resources.getTable().setLayoutData(resourcesData);
    for (ViewerFilter filter : this.resourcesFilters) {
      resources.addFilter(filter);
    }
    EditingUtils.setID(resources.getTable(), DeploymentViewsRepository.DeployedResource.DeployedResources.resources);
    EditingUtils.setEEFtype(resources.getTable(), "eef::TableComposition::field"); //$NON-NLS-1$
    createResourcesPanel(widgetFactory, tableContainer);
    return container;
  }

	/**
   * @param container
   * @generated
   */
  protected Composite createResourcesPanel(FormToolkit widgetFactory, Composite container) {
    Composite resourcesPanel = widgetFactory.createComposite(container, SWT.NONE);
    GridLayout resourcesPanelLayout = new GridLayout();
    resourcesPanelLayout.numColumns = 1;
    resourcesPanel.setLayout(resourcesPanelLayout);
    Button addResources = widgetFactory.createButton(resourcesPanel, DeploymentMessages.PropertiesEditionPart_AddTableViewerLabel, SWT.NONE);
    addResources.setEnabled(false);
    addResources.setToolTipText(DeploymentMessages.DeployedResource_ReadOnly);
    GridData addResourcesData = new GridData(GridData.FILL_HORIZONTAL);
    addResources.setLayoutData(addResourcesData);
    addResources.addSelectionListener(new SelectionAdapter() {

      /**
       * {@inheritDoc}
       * 
       * @see org.eclipse.swt.events.SelectionAdapter#widgetSelected(org.eclipse.swt.events.SelectionEvent)
       * @generated
       */
      public void widgetSelected(SelectionEvent e) {
        propertiesEditionComponent.firePropertiesChanged(new PropertiesEditionEvent(DeployedResourcePropertiesEditionPartForm.this, DeploymentViewsRepository.DeployedResource.DeployedResources.resources, PropertiesEditionEvent.COMMIT, PropertiesEditionEvent.ADD, null, null));
        resources.refresh();
      }
    });
    EditingUtils.setID(addResources, DeploymentViewsRepository.DeployedResource.DeployedResources.resources);
    EditingUtils.setEEFtype(addResources, "eef::TableComposition::addbutton"); //$NON-NLS-1$
    Button removeResources = widgetFactory.createButton(resourcesPanel, DeploymentMessages.PropertiesEditionPart_RemoveTableViewerLabel, SWT.NONE);
    removeResources.setEnabled(false);
    removeResources.setToolTipText(DeploymentMessages.DeployedResource_ReadOnly);
    GridData removeResourcesData = new GridData(GridData.FILL_HORIZONTAL);
    removeResources.setLayoutData(removeResourcesData);
    removeResources.addSelectionListener(new SelectionAdapter() {

      /**
       * {@inheritDoc}
       * 
       * @see org.eclipse.swt.events.SelectionAdapter#widgetSelected(org.eclipse.swt.events.SelectionEvent)
       * @generated
       */
      public void widgetSelected(SelectionEvent e) {
        if (resources.getSelection() instanceof IStructuredSelection) {
          IStructuredSelection selection = (IStructuredSelection) resources.getSelection();
          if (selection.getFirstElement() instanceof EObject) {
            EObject selectedElement = (EObject) selection.getFirstElement();
            propertiesEditionComponent.firePropertiesChanged(new PropertiesEditionEvent(DeployedResourcePropertiesEditionPartForm.this, DeploymentViewsRepository.DeployedResource.DeployedResources.resources, PropertiesEditionEvent.CHANGE, PropertiesEditionEvent.REMOVE, null, selectedElement));
            resources.refresh();
          }
        }
      }

    });
    EditingUtils.setID(removeResources, DeploymentViewsRepository.DeployedResource.DeployedResources.resources);
    EditingUtils.setEEFtype(removeResources, "eef::TableComposition::removebutton"); //$NON-NLS-1$
    Button editResources = widgetFactory.createButton(resourcesPanel, DeploymentMessages.PropertiesEditionPart_EditTableViewerLabel, SWT.NONE);
    editResources.setEnabled(false);
    editResources.setToolTipText(DeploymentMessages.DeployedResource_ReadOnly);
    GridData editResourcesData = new GridData(GridData.FILL_HORIZONTAL);
    editResources.setLayoutData(editResourcesData);
    editResources.addSelectionListener(new SelectionAdapter() {

      /**
       * {@inheritDoc}
       * 
       * @see org.eclipse.swt.events.SelectionAdapter#widgetSelected(org.eclipse.swt.events.SelectionEvent)
       * @generated
       */
      public void widgetSelected(SelectionEvent e) {
        if (resources.getSelection() instanceof IStructuredSelection) {
          IStructuredSelection selection = (IStructuredSelection) resources.getSelection();
          if (selection.getFirstElement() instanceof EObject) {
            propertiesEditionComponent.firePropertiesChanged(new PropertiesEditionEvent(DeployedResourcePropertiesEditionPartForm.this, DeploymentViewsRepository.DeployedResource.DeployedResources.resources, PropertiesEditionEvent.COMMIT, PropertiesEditionEvent.EDIT, null, selection.getFirstElement()));
            resources.refresh();
          }
        }
      }

    });
    EditingUtils.setID(editResources, DeploymentViewsRepository.DeployedResource.DeployedResources.resources);
    EditingUtils.setEEFtype(editResources, "eef::TableComposition::editbutton"); //$NON-NLS-1$
    return resourcesPanel;
  }

  /**
   * @generated
   */
  protected Composite createDeployedSharedResourcesGroup(FormToolkit widgetFactory, final Composite parent) {
    Section deployedSharedResourcesSection = widgetFactory.createSection(parent, Section.TITLE_BAR | Section.TWISTIE | Section.EXPANDED);
    deployedSharedResourcesSection.setText(DeploymentMessages.DeployedResourcePropertiesEditionPart_DeployedSharedResourcesGroupLabel);
    GridData deployedSharedResourcesSectionData = new GridData(GridData.FILL_HORIZONTAL);
    deployedSharedResourcesSectionData.horizontalSpan = 3;
    deployedSharedResourcesSection.setLayoutData(deployedSharedResourcesSectionData);
    Composite deployedSharedResourcesGroup = widgetFactory.createComposite(deployedSharedResourcesSection);
    GridLayout deployedSharedResourcesGroupLayout = new GridLayout();
    deployedSharedResourcesGroupLayout.numColumns = 3;
    deployedSharedResourcesGroup.setLayout(deployedSharedResourcesGroupLayout);
    deployedSharedResourcesSection.setClient(deployedSharedResourcesGroup);
    return deployedSharedResourcesGroup;
  }

  /**
	 * @param container
	 * @generated
	 */
	protected Composite createSharedResourcesTableComposition(FormToolkit widgetFactory, Composite container) {
    Composite tableContainer = widgetFactory.createComposite(container, SWT.NONE);
    GridLayout tableContainerLayout = new GridLayout();
    GridData tableContainerData = new GridData(GridData.FILL_BOTH);
    tableContainerData.horizontalSpan = 3;
    tableContainer.setLayoutData(tableContainerData);
    tableContainerLayout.numColumns = 2;
    tableContainer.setLayout(tableContainerLayout);
    org.eclipse.swt.widgets.Table tableSharedResources = widgetFactory.createTable(tableContainer, SWT.FULL_SELECTION | SWT.BORDER);
    tableSharedResources.setHeaderVisible(true);
    tableSharedResources.setEnabled(false);
    tableSharedResources.setToolTipText(DeploymentMessages.DeployedResource_ReadOnly);
    GridData gdSharedResources = new GridData();
    gdSharedResources.grabExcessHorizontalSpace = true;
    gdSharedResources.horizontalAlignment = GridData.FILL;
    gdSharedResources.grabExcessVerticalSpace = true;
    gdSharedResources.verticalAlignment = GridData.FILL;
    tableSharedResources.setLayoutData(gdSharedResources);
    tableSharedResources.setLinesVisible(true);

        TableColumn name = new TableColumn(tableSharedResources, SWT.NONE);
        name.setWidth(80);
        name.setText("Label"); //$NON-NLS-1$
    

    sharedResources = new TableViewer(tableSharedResources);
    sharedResources.setContentProvider(new ArrayContentProvider());
    sharedResources.setLabelProvider(new ITableLabelProvider() {
            public String getColumnText(Object object, int columnIndex) {
              AdapterFactoryLabelProvider labelProvider = new AdapterFactoryLabelProvider(adapterFactory);
              if (object instanceof EObject) {
                switch (columnIndex) {
                case 0:
                  return labelProvider.getText(object);
                }
              }
              return ""; //$NON-NLS-1$
            }
      
            public Image getColumnImage(Object element, int columnIndex) {
              return null;
            }
      

      public void addListener(ILabelProviderListener listener) {
      }

      public void dispose() {
      }

      public boolean isLabelProperty(Object element, String property) {
        return false;
      }

      public void removeListener(ILabelProviderListener listener) {
      }

    });
    sharedResources.getTable().addListener(SWT.MouseDoubleClick, new Listener(){

      public void handleEvent(Event event) {
        if (sharedResources.getSelection() instanceof IStructuredSelection) {
          IStructuredSelection selection = (IStructuredSelection) sharedResources.getSelection();
          if (selection.getFirstElement() instanceof EObject) {
            propertiesEditionComponent.firePropertiesChanged(new PropertiesEditionEvent(DeployedResourcePropertiesEditionPartForm.this, DeploymentViewsRepository.DeployedResource.DeployedSharedResources.sharedResources, PropertiesEditionEvent.COMMIT, PropertiesEditionEvent.EDIT, null, selection.getFirstElement()));
            sharedResources.refresh();
          }
        }
      }

    });
    GridData sharedResourcesData = new GridData(GridData.FILL_HORIZONTAL);
    sharedResourcesData.minimumHeight = 120;
    sharedResourcesData.heightHint = 120;
    sharedResources.getTable().setLayoutData(sharedResourcesData);
    for (ViewerFilter filter : this.sharedResourcesFilters) {
      sharedResources.addFilter(filter);
    }
    EditingUtils.setID(sharedResources.getTable(), DeploymentViewsRepository.DeployedResource.DeployedSharedResources.sharedResources);
    EditingUtils.setEEFtype(sharedResources.getTable(), "eef::TableComposition::field"); //$NON-NLS-1$
    createSharedResourcesPanel(widgetFactory, tableContainer);
    return container;
  }



	/**
   * @param container
   * @generated
   */
  protected Composite createSharedResourcesPanel(FormToolkit widgetFactory, Composite container) {
    Composite sharedResourcesPanel = widgetFactory.createComposite(container, SWT.NONE);
    GridLayout sharedResourcesPanelLayout = new GridLayout();
    sharedResourcesPanelLayout.numColumns = 1;
    sharedResourcesPanel.setLayout(sharedResourcesPanelLayout);
    Button addSharedResources = widgetFactory.createButton(sharedResourcesPanel, DeploymentMessages.PropertiesEditionPart_AddTableViewerLabel, SWT.NONE);
    addSharedResources.setEnabled(false);
    addSharedResources.setToolTipText(DeploymentMessages.DeployedResource_ReadOnly);
    GridData addSharedResourcesData = new GridData(GridData.FILL_HORIZONTAL);
    addSharedResources.setLayoutData(addSharedResourcesData);
    addSharedResources.addSelectionListener(new SelectionAdapter() {

      /**
       * {@inheritDoc}
       * 
       * @see org.eclipse.swt.events.SelectionAdapter#widgetSelected(org.eclipse.swt.events.SelectionEvent)
       * @generated
       */
      public void widgetSelected(SelectionEvent e) {
        propertiesEditionComponent.firePropertiesChanged(new PropertiesEditionEvent(DeployedResourcePropertiesEditionPartForm.this, DeploymentViewsRepository.DeployedResource.DeployedSharedResources.sharedResources, PropertiesEditionEvent.COMMIT, PropertiesEditionEvent.ADD, null, null));
        sharedResources.refresh();
      }
    });
    EditingUtils.setID(addSharedResources, DeploymentViewsRepository.DeployedResource.DeployedSharedResources.sharedResources);
    EditingUtils.setEEFtype(addSharedResources, "eef::TableComposition::addbutton"); //$NON-NLS-1$
    Button removeSharedResources = widgetFactory.createButton(sharedResourcesPanel, DeploymentMessages.PropertiesEditionPart_RemoveTableViewerLabel, SWT.NONE);
    removeSharedResources.setEnabled(false);
    removeSharedResources.setToolTipText(DeploymentMessages.DeployedResource_ReadOnly);
    GridData removeSharedResourcesData = new GridData(GridData.FILL_HORIZONTAL);
    removeSharedResources.setLayoutData(removeSharedResourcesData);
    removeSharedResources.addSelectionListener(new SelectionAdapter() {

      /**
       * {@inheritDoc}
       * 
       * @see org.eclipse.swt.events.SelectionAdapter#widgetSelected(org.eclipse.swt.events.SelectionEvent)
       * @generated
       */
      public void widgetSelected(SelectionEvent e) {
        if (sharedResources.getSelection() instanceof IStructuredSelection) {
          IStructuredSelection selection = (IStructuredSelection) sharedResources.getSelection();
          if (selection.getFirstElement() instanceof EObject) {
            EObject selectedElement = (EObject) selection.getFirstElement();
            propertiesEditionComponent.firePropertiesChanged(new PropertiesEditionEvent(DeployedResourcePropertiesEditionPartForm.this, DeploymentViewsRepository.DeployedResource.DeployedSharedResources.sharedResources, PropertiesEditionEvent.CHANGE, PropertiesEditionEvent.REMOVE, null, selectedElement));
            sharedResources.refresh();
          }
        }
      }

    });
    EditingUtils.setID(removeSharedResources, DeploymentViewsRepository.DeployedResource.DeployedSharedResources.sharedResources);
    EditingUtils.setEEFtype(removeSharedResources, "eef::TableComposition::removebutton"); //$NON-NLS-1$
    Button editSharedResources = widgetFactory.createButton(sharedResourcesPanel, DeploymentMessages.PropertiesEditionPart_EditTableViewerLabel, SWT.NONE);
    editSharedResources.setEnabled(false);
    editSharedResources.setToolTipText(DeploymentMessages.DeployedResource_ReadOnly);
    GridData editSharedResourcesData = new GridData(GridData.FILL_HORIZONTAL);
    editSharedResources.setLayoutData(editSharedResourcesData);
    editSharedResources.addSelectionListener(new SelectionAdapter() {

      /**
       * {@inheritDoc}
       * 
       * @see org.eclipse.swt.events.SelectionAdapter#widgetSelected(org.eclipse.swt.events.SelectionEvent)
       * @generated
       */
      public void widgetSelected(SelectionEvent e) {
        if (sharedResources.getSelection() instanceof IStructuredSelection) {
          IStructuredSelection selection = (IStructuredSelection) sharedResources.getSelection();
          if (selection.getFirstElement() instanceof EObject) {
            propertiesEditionComponent.firePropertiesChanged(new PropertiesEditionEvent(DeployedResourcePropertiesEditionPartForm.this, DeploymentViewsRepository.DeployedResource.DeployedSharedResources.sharedResources, PropertiesEditionEvent.COMMIT, PropertiesEditionEvent.EDIT, null, selection.getFirstElement()));
            sharedResources.refresh();
          }
        }
      }

    });
    EditingUtils.setID(editSharedResources, DeploymentViewsRepository.DeployedResource.DeployedSharedResources.sharedResources);
    EditingUtils.setEEFtype(editSharedResources, "eef::TableComposition::editbutton"); //$NON-NLS-1$
    return sharedResourcesPanel;
  }

  /**
	 * {@inheritDoc}
	 * 
	 * @see org.eclipse.emf.eef.runtime.api.notify.IPropertiesEditionListener#firePropertiesChanged(org.eclipse.emf.eef.runtime.api.notify.IPropertiesEditionEvent)
	 * @generated
	 */
	public void firePropertiesChanged(IPropertiesEditionEvent event) {
  }



	/**
	 * {@inheritDoc}
	 * 
	 * @see org.omg.deployment.parts.DeployedResourcePropertiesEditionPart#initResources(EObject current, EReference containingFeature, EReference feature)
	 */
	public void initResources(ReferencesTableSettings settings) {
		if (current.eResource() != null && current.eResource().getResourceSet() != null)
			this.resourceSet = current.eResource().getResourceSet();
		ReferencesTableContentProvider contentProvider = new ReferencesTableContentProvider();
		resources.setContentProvider(contentProvider);
		resources.setInput(settings);
	}

	/**
	 * {@inheritDoc}
	 * 
	 * @see org.omg.deployment.parts.DeployedResourcePropertiesEditionPart#updateResources()
	 * @generated
	 */
	public void updateResources() {
  resources.refresh();
}

	/**
	 * {@inheritDoc}
	 * 
	 * @see org.omg.deployment.parts.DeployedResourcePropertiesEditionPart#addFilterResources(ViewerFilter filter)
	 * @generated
	 */
	public void addFilterToResources(ViewerFilter filter) {
    resourcesFilters.add(filter);
    if (this.resources != null) {
      this.resources.addFilter(filter);
    }
  }

	/**
	 * {@inheritDoc}
	 * 
	 * @see org.omg.deployment.parts.DeployedResourcePropertiesEditionPart#addBusinessFilterResources(ViewerFilter filter)
	 * @generated
	 */
	public void addBusinessFilterToResources(ViewerFilter filter) {
    resourcesBusinessFilters.add(filter);
  }

	/**
	 * {@inheritDoc}
	 * 
	 * @see org.omg.deployment.parts.DeployedResourcePropertiesEditionPart#isContainedInResourcesTable(EObject element)
	 * @generated
	 */
	public boolean isContainedInResourcesTable(EObject element) {
    return ((ReferencesTableSettings)resources.getInput()).contains(element);
  }




	/**
	 * {@inheritDoc}
	 * 
	 * @see org.omg.deployment.parts.DeployedResourcePropertiesEditionPart#initSharedResources(EObject current, EReference containingFeature, EReference feature)
	 */
	public void initSharedResources(ReferencesTableSettings settings) {
		if (current.eResource() != null && current.eResource().getResourceSet() != null)
			this.resourceSet = current.eResource().getResourceSet();
		ReferencesTableContentProvider contentProvider = new ReferencesTableContentProvider();
		sharedResources.setContentProvider(contentProvider);
		sharedResources.setInput(settings);
	}

	/**
	 * {@inheritDoc}
	 * 
	 * @see org.omg.deployment.parts.DeployedResourcePropertiesEditionPart#updateSharedResources()
	 * @generated
	 */
	public void updateSharedResources() {
  sharedResources.refresh();
}

	/**
	 * {@inheritDoc}
	 * 
	 * @see org.omg.deployment.parts.DeployedResourcePropertiesEditionPart#addFilterSharedResources(ViewerFilter filter)
	 * @generated
	 */
	public void addFilterToSharedResources(ViewerFilter filter) {
    sharedResourcesFilters.add(filter);
    if (this.sharedResources != null) {
      this.sharedResources.addFilter(filter);
    }
  }

	/**
	 * {@inheritDoc}
	 * 
	 * @see org.omg.deployment.parts.DeployedResourcePropertiesEditionPart#addBusinessFilterSharedResources(ViewerFilter filter)
	 * @generated
	 */
	public void addBusinessFilterToSharedResources(ViewerFilter filter) {
    sharedResourcesBusinessFilters.add(filter);
  }

	/**
	 * {@inheritDoc}
	 * 
	 * @see org.omg.deployment.parts.DeployedResourcePropertiesEditionPart#isContainedInSharedResourcesTable(EObject element)
	 * @generated
	 */
	public boolean isContainedInSharedResourcesTable(EObject element) {
    return ((ReferencesTableSettings)sharedResources.getInput()).contains(element);
  }




	/**
	 * {@inheritDoc}
	 *
	 * @see org.eclipse.emf.eef.runtime.api.parts.IPropertiesEditionPart#getTitle()
	 * @generated
	 */
	public String getTitle() {
    return DeploymentMessages.DeployedResource_Part_Title;
  }



}
